package StudyCode.summary.regularexpressionsmatch;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class RegularExpressionSearchProgramTemplate {
	public static void main(String[] args) {
		String patternStr = "b";
		Pattern pattern = Pattern.compile(patternStr);

		CharSequence inputStr = "a b c b";
		Matcher matcher = pattern.matcher(inputStr);
		boolean matchFound = matcher.find();
		System.out.println(matchFound);

		String match = matcher.group(); // b
		System.out.println(match);

		int start = matcher.start(); // 2
		System.out.println(start);
		int end = matcher.end(); // 3
		System.out.println(end);
		matchFound = matcher.find(); // true
		System.out.println(matchFound);
	}

}
